﻿using System.Diagnostics;
using LFSRecord2.Model.Undo;

namespace LFSRecord2.Model.UserActions
{
    public class UserActionDeleteLayer : UserActionBase
    {
        // Action description, so we can replay this action (and reverse it)
        public int LayerIndex { get; set; }

        /// <summary>
        /// The full layer data copy. With that we know how to reverse and replay it.
        /// </summary>
        public LayerData Layer { get; set; }

        public UserActionDeleteLayer()
        {
            Action = UserActionTypes.DeleteLayer;
        }

        public override void DoUndo()
        {
            Debug.WriteLine("Undoing a DeleteLayer action");
            LfsRecordController.project.ReinstateLayer(Layer);
            LfsRecordController.project.Layers[Layer.LayerIndex].UpdatedCurrentValues = CompLayerPropertyUpdateTypes.All;
        }

        public override void DoRedo()
        {
            Debug.WriteLine("Redoing a DeleteLayer action");
            LfsRecordController.project.DeleteLayer(LfsRecordController.project.Layers[LayerIndex]);
        }
    }
}
